#include <bits/stdc++.h>
using namespace std;
int n,lst[200005],col[200005],ans=0;
int calc(int length){
    int sum=0;
    for(int i=length-1;i>=0;i--){
        int tag=1;
        for(int j=i-1;j>=0;j--){
            //cout<<i<<" "<<j<<" "<<lst[i]<<" "<<lst[j]<<endl;
            if(col[i]==col[j] && tag==1){
                if(lst[i]==lst[j]){
                    //cout<<lst[i]<<" "<<lst[j]<<endl;
                    sum+=lst[i];
                }
                tag=0;
            }
        }
    }
    return sum;
}
int search(int now,int tot){
    if(now==tot){
        /*
        for(int i=0;i<tot;i++){
            cout<<col[i];
        }//cout<<"tot"<<calc(tot)<<endl;
        //cout<<ans<<" "<<calc(tot)<<" "<<max(calc(tot),ans)<<endl;*/
        ans=max(calc(tot),ans);
    }else{
        col[now]=1;
        search(now+1,tot);
        col[now]=0;
        search(now+1,tot);
    }
    return ans;
}
int main(){//20pts O(2^n)
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        ans=0;
        cin>>n;
        for(int j=0;j<n;j++){
            cin>>lst[j];
        }
        cout<<search(0,n)<<endl;
    }
    return 0;
}